package com.situ.feemanagement.controller;

import com.situ.feemanagement.pojo.Auth;
import com.situ.feemanagement.pojo.query.AuthQuery;
import com.situ.feemanagement.service.IAuthService;
import com.situ.feemanagement.util.PageResult;
import com.situ.feemanagement.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/auth")
public class AuthController {

    @Autowired
    private IAuthService authService;

    @RequestMapping("/selectByPage")
    public PageResult<Auth> selectByPage(AuthQuery authQuery) {
        return authService.selectByPage(authQuery);
    }

    @RequestMapping("/deleteById")
    public Result deleteById(String id) {
        authService.deleteById(Integer.parseInt(id));
        return Result.ok("删除成功");
    }

    @RequestMapping("/deleteAll")
    public Result deleteAll(String[] ids) {
        authService.deleteAll(ids);
        return  Result.ok("删除成功");
    }

    @RequestMapping("/add")
    public Result add(Auth auth) {
        authService.add(auth);
        return Result.ok("添加成功");
    }

    @RequestMapping("/selectById")
    public Result selectById(String id) {
        Auth auth = authService.selectById(Integer.parseInt(id));
        return Result.ok(auth);
    }

    @RequestMapping("/update")
    public Result update(Auth auth) {
        authService.Update(auth);
        return Result.ok("修改成功");
    }

    @RequestMapping("/updateStatus")
    public Result updateStatus(String id, String status) {
        authService.updateStatus(Integer.parseInt(id),Integer.parseInt(status));
        return Result.ok("更新成功");
    }
}
